package com.stuinfo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class SelectShow extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextArea ta;


	public SelectShow(SelectWay selectWay, boolean b) {
		super(selectWay, b);
		ta = new JTextArea();
		ta.setLineWrap(true);
		JScrollPane sp = new JScrollPane(ta);
		add(sp);

	
	}
	public void allSelect(Connection conn) {
		String sql_select = "select * from stuinfo order by id";
		PreparedStatement pre_select;
		try {
			pre_select = conn.prepareStatement(sql_select);
			ResultSet resu = pre_select.executeQuery();
			while (resu.next()) {
			ta.append((resu.getInt("id") + "\t" + resu.getString("name") + "\t" + resu.getString("sex"))+"\n");
			//System.out.println(resu.getInt("id") + "\t" + resu.getString("name") + "\t" + resu.getString("sex"));
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
